#ifndef _CSCROLLBAR_H_
#define _CSCROLLBAR_H_

#include <buola/gui/cwindow.h>
#include <buola/widgets/csliderwidget.h>

namespace buola { namespace gui {

///\addtogroup widgets
///@{

////////////////////////////////////////////////////////////////////////////

/// scroll bar

///
///
///
////////////////////////////////////////////////////////////////////////////

class CScrollBar : public CSliderWidget<int>
{
public:
//! \name constructor and destructor
//@{
    CScrollBar();
    virtual ~CScrollBar();
//@}

//! \name public interface
//@{
    void Scroll(int pAmount);
//@}

//! \name functions for drawing
//@{
    double GetBarTop()          {   return mBarTop;         }
    double GetBarBottom()       {   return mBarBottom;      }
    double GetCursorTop()       {   return mCursorTop;      }
    double GetCursorBottom()    {   return mCursorBottom;   }
//@}

private:
//! \name event handling
//@{
    virtual void OnExpose(const CExposeEvent &pE);
    virtual void OnButtonDown(const CMouseEvent &pE);
    virtual void OnButtonUp(const CMouseEvent &pE);
    virtual void OnMouseIn(const CMouseEvent &pE);
    virtual void OnMouseOut(const CMouseEvent &pE);
    virtual void OnMouseMove(const CMouseEvent &pE);
    virtual void OnMouseWheel(const CMouseEvent &pE);
    virtual void OnFocusIn(const CFocusEvent &pE);
    virtual void OnFocusOut(const CFocusEvent &pE);
    virtual void OnKeyDown(const CKeyEvent &pE);
    virtual void OnSize(const CGeometryEvent &pE);
    virtual void OnStyleChanged(TStyle);

    virtual void OnSWChange();
//@}

private:
//! \name internal functions
//@{
    void Shape();

    void CalcBar();
    void CalcPos();
//@}

private:
    double mBarTop;
    double mBarBottom;
    double mCursorTop;
    double mCursorBottom;

    bool mDragging;
    double mDragStart;
    double mDragPos;

    bool mInside;
    bool mDontUpdateBar;
};

///@}

/*namespace gui*/ } /*namespace buola*/ }

#endif
